package hn.sigit.model.ladm.spatialunit;

import java.io.Serializable;
import javax.persistence.*;

import org.hibernate.annotations.Type;

import com.vividsolutions.jts.geom.Point;
@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="LA_SpatialUnitGroup", schema="ladm_spatialunit")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorValue("LA_SpatialUnitGroup")
public class LA_SpatialUnitGroup extends hn.sigit.model.ladm.special.VersionedObject implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long sugID;
	private LA_SpatialUnitGroup set;
	private int hierarchyLevel;
	private String label;
	private String name;
	private Point referencePoint;
	private java.util.Set<LA_SpatialUnit> part = new java.util.HashSet<LA_SpatialUnit>();
	private java.util.Set<LA_SpatialUnitGroup> element = new java.util.HashSet<LA_SpatialUnitGroup>();

	public LA_SpatialUnitGroup() {
	}
	
	@Id
	@Column(name="ID", nullable=false)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="la_spatialunitgroup_id_gen")
	@SequenceGenerator(name="la_spatialunitgroup_id_gen", sequenceName="la_spatialunitgroup_id_seq", allocationSize=1)
	public long getSugID() {
		return sugID;
	}
	protected void setSugID(long value) {
		this.sugID = value;
	}
	@Transient
	public long getORMID() {
		return getSugID();
	}
	
	@Column(name="HierarchyLevel", nullable=false)
	public int getHierarchyLevel() {
		return hierarchyLevel;
	}
	public void setHierarchyLevel(int value) {
		this.hierarchyLevel = value;
	}
	
	@Column(name="Label", nullable=true, length=255)
	public String getLabel() {
		return label;
	}
	public void setLabel(String value) {
		this.label = value;
	}
	
	@Column(name="Name", nullable=true, length=255)
	public String getName() {
		return name;
	}
	public void setName(String value) {
		this.name = value;
	}
	
	@Column(name="ReferencePoint", nullable=false)
	@Type(type = "org.hibernatespatial.GeometryUserType")
	public Point getReferencePoint() {
		return referencePoint;
	}
	public void setReferencePoint(Point value) {
		this.referencePoint = value;
	}
	
	@ManyToOne(targetEntity=LA_SpatialUnitGroup.class, fetch=FetchType.LAZY)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="LA_SpatialUnitGroupID", referencedColumnName="ID") })	
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)	
	public LA_SpatialUnitGroup getSet() {
		return set;
	}
	public void setSet(LA_SpatialUnitGroup value) {
		this.set = value;
	}
	
	@ManyToMany(mappedBy="whole", targetEntity=LA_SpatialUnit.class)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)
	public java.util.Set<LA_SpatialUnit> getPart() {
		return part;
	}
	public void setPart(java.util.Set<LA_SpatialUnit> value) {
		this.part = value;
	}
	
	@OneToMany(mappedBy="set", targetEntity=LA_SpatialUnitGroup.class)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)
	public java.util.Set<LA_SpatialUnitGroup> getElement() {
		return element;
	}
	public void setElement(java.util.Set<LA_SpatialUnitGroup> value) {
		this.element = value;
	}
	
	
	public String toString() {
		return super.toString();
	}
	
}
